<?php
require('includes/model.php');
require('includes/default.php');

$form = new XA_EditForm($table_name);

$form->load($_GET);
$form->action = xa::url('action=edit_handle&model='.$table_name);
$form->id = $table_name.'_edit';

$form->title = $form->record_exists ? 'Edycja' : 'Nowy';

$page->title = $form->title.' - '.$model['name'].(defined('MODULE_NAME') ? ' - '.MODULE_NAME : '').' - '.SITE_NAME;

$content_template = MODULE_PATH.'templates/edit.php';

$fl =& $form->field_list;

if (file_exists($fn = MODULE_PATH.'model/'.$table_name.'_edit.php')) {
	include($fn);
}

$form->setLabels($model['label_list']);
$form->setPositions(array_keys($model['label_list']));

$page->content['form'] = $form;
$page->content['table_name'] = $table_name;

$page->template = 'edit';
echo $page->out();
